package com.realgodo.site.entity.application;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.realgodo.site.entity.IdEntity;
import com.realgodo.site.entity.space.Space;

/**
 * @author bijiqiang E-mail: bijiqiang@gmail.com
 * @version 创建时间：2009-12-12下午10:26:21
 * @since jdk1.5
 * @version 0.1
 */
@Entity(name = "Application")
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name = "application")
public class Application extends IdEntity {

	private static final long serialVersionUID = 2053437277173951828L;
//	public static final int TYPE_UNDEFINE = 0;
	public static final String TYPE_NAME_MOOD = "纠结";
	public static final String TYPE_NAME_FAVORITE = "收藏";
	public static final String TYPE_NAME_SECRET = "秘密";
	public static final String TYPE_NAME_MUSIC = "音乐";
	/**实际子类型*/
	@SuppressWarnings("unchecked")
	private Class clasz;
	
	/**应用类型*/
	private String typeName;

	private Space space;

	private Date pubTime = new Date();
	/** 评论数量，用于热门查询 */
	private Integer commentaries = 0;

	public Integer getCommentaries() {
		return commentaries;
	}

	public void setCommentaries(Integer commentary) {
		this.commentaries = commentary;
	}

//	public int getType() {
//		return type;
//	}
//
//	public void setType(int type) {
//		this.type = type;
//	}

	@ManyToOne
	@JoinColumn(name = "space_id", referencedColumnName = "id", nullable = false)
	public Space getSpace() {
		return space;
	}

	public void setSpace(Space space) {
		this.space = space;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "pub_time", insertable = true, updatable = true)
	public Date getPubTime() {
		return pubTime;
	}

	public void setPubTime(Date pubTime) {
		this.pubTime = pubTime;
	}

	@SuppressWarnings("unchecked")
	@JoinColumn(name = "clasz", nullable = false)
	public Class getClasz() {
		return clasz;
	}

	@SuppressWarnings("unchecked")
	public void setClasz(Class clasz) {
		this.clasz = clasz;
	}
	
	@Column(name = "type_name", insertable = true, updatable = true)
	public String getTypeName() {
		return typeName;
	}

	public void setTypeName(String typeName) {
		this.typeName = typeName;
	}
	
	

}
